<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" id="input">
    <button id="submit">
        点击我发送数据
    </button>
    <div>
        渲染框
        <ul id="content">

        </ul>
    </div>
    <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="./socket.io.js"></script>
    <script>
        let socket = io()

        $('#submit').on('click', function() {
            socket.emit('getMessage', $('#input').val())
        })

        socket.on('allChat', function(msg) {
            $('#content').append($('<li>').text(msg));
        });
    </script>
</body>

</html>